//
//  HeaderLabelView.m
//  记账deam
//
//  Created by apple on 16/5/6.
//  Copyright © 2016年 --- 杨江 ---. All rights reserved.
//

#import "HeaderLabelView.h"

@implementation HeaderLabelView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor greenColor];
    }
    return self;
}

- (void)initTheUI{
    [self addSubview:self.logoImg];
    [self addSubview:self.classNameLabel];
    [self addSubview:self.moneyLabel];
}

- (void)setMessageSize:(CGSize)messageSize {
    _messageSize = messageSize;
//    _classNameLabel.bounds = CRM(0, 0, messageSize.width + 10, 15*PROPORTION_H);
//    _classNameLabel.center = CPM(CGRectGetMidX(self.frame), 40*PROPORTION_H + 7.5*PROPORTION_H);
    _classNameLabel.frame = CRM(50 *PROPORTION_W, 22 *PROPORTION_H, _messageSize.width +10, _messageSize.height);
    [self initTheUI];
    
}

#pragma mark -- Getter
//
- (UIImageView *)logoImg{
    if (!_logoImg) {
        _logoImg = [[UIImageView alloc]initWithFrame:CRM(10 *PROPORTION_W, 10 *PROPORTION_H, 32 *PROPORTION_H, 32*PROPORTION_H)];
        _logoImg.center = CPM(26*PROPORTION_W, CGRectGetHeight(self.bounds)/2);
    }
    return _logoImg;
}
- (UILabel *)classNameLabel{
    if (!_classNameLabel) {
        _classNameLabel = [[UILabel alloc]initWithFrame:CRM(50 *PROPORTION_W, 30 *PROPORTION_H, _messageSize.width +10, _messageSize.height)];
        _classNameLabel.font = [UIFont systemFontOfSize:14];
        _classNameLabel.center = CPM(50 *PROPORTION_W +_messageSize.width/2, CGRectGetHeight(self.bounds)/2);

    }

    return _classNameLabel;
}
- (UILabel *)moneyLabel{
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]initWithFrame:CRM(CGRectGetWidth(self.bounds)-160 *PROPORTION_W, 10 *PROPORTION_H, 150 *PROPORTION_W, 32)];
        _moneyLabel.text = @"0.00";
        _moneyLabel.textAlignment = NSTextAlignmentRight;
        _moneyLabel.font = [UIFont systemFontOfSize:24];
    }


    return _moneyLabel;
}
@end
